package com.hsomandroidapp.component;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.hsomandroidapp.R;

public class CommonFoot extends LinearLayout{

	private Context context;
	private RelativeLayout productLayout;
	private RelativeLayout estoreLayout;
	private RelativeLayout cartLayout;
	private RelativeLayout chargeLayout;

	
	public CommonFoot(Context context) {
		super(context);
		this.context = context;
		init();
	}
	public CommonFoot(Context paramContext, AttributeSet paramAttributeSet) {
		super(paramContext, paramAttributeSet);
		this.context = paramContext;
		init();
	}
	
	private void init(){
		View footView = ((LayoutInflater) getContext().getSystemService(
				Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.common_foot, this);
		productLayout = (RelativeLayout)footView.findViewById(R.id.rl_product);
		estoreLayout = (RelativeLayout)footView.findViewById(R.id.rl_estore);
		cartLayout = (RelativeLayout)footView.findViewById(R.id.rl_cart);
		chargeLayout = (RelativeLayout)footView.findViewById(R.id.rl_charge);
	}
	
	public void setLayoutOnClickListener(OnClickListener listenner1,OnClickListener listenner2,OnClickListener listenner3,OnClickListener listenner4)
	{
		productLayout.setOnClickListener(listenner1);
		estoreLayout.setOnClickListener(listenner2);
		cartLayout.setOnClickListener(listenner3);
		chargeLayout.setOnClickListener(listenner4);

	}
	public void onClickMode(int index){
		switch(index){
		case 0:
			productLayout.setBackgroundResource(R.drawable.foot_bg_select);
			estoreLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			cartLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			chargeLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			break;
		case 1:
			productLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			estoreLayout.setBackgroundResource(R.drawable.foot_bg_select);
			cartLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			chargeLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			break;
		case 2:
			productLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			estoreLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			cartLayout.setBackgroundResource(R.drawable.foot_bg_select);
			chargeLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			break;
		case 3:
			productLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			estoreLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			cartLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			chargeLayout.setBackgroundResource(R.drawable.foot_bg_select);
			break;
		case 99:
			productLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			estoreLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			cartLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			chargeLayout.setBackgroundResource(R.drawable.foot_bg_no_select);
			break;
		}
	}
		

}
